package xc.src.demo;


import org.apache.commons.io.FileUtils;

import java.io.File;
import java.io.IOException;
import java.net.URL;

//练习thread,实现多线程同步下同步下载图片
public class testThread2 implements Runnable{

    private String url;//网络图片地址
    private String name;//保存的文件名

    public testThread2(String url, String name){
        this.url=url;
        this.name=name;
    }

//下载图片线程的执行体
    @Override
    public void run() {
    WebDownloader webDownloader = new WebDownloader();
    webDownloader.downloader(url,name);
        System.out.println("下载了文件名为:"+name);
}

//主线程
    public static void main(String[] args) {
        //创建三个线程
        testThread2 testThread1 = new testThread2("https://qn-sfe.yuketang.cn/o_1c9oq0sec149j1g47ccl10urj0tg.png","1,jpg");
        testThread2 testThread2 = new testThread2("https://qn-sfe.yuketang.cn/o_1c9oq0sec149j1g47ccl10urj0tg.png","2,jpg");
        xc.src.demo.testThread2 testThread3 = new testThread2("https://qn-sfe.yuketang.cn/o_1c9oq0sec149j1g47ccl10urj0tg.png","3,jpg");

        new Thread(testThread1).start();
        new Thread(testThread2).start();
        new Thread(testThread3).start();

    }
}


